package com.xzm;

import java.io.*;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;

public class SerTest {
    public static void main(String[] args) throws IOException, ClassNotFoundException {
/*        ObjectOutputStream os = new ObjectOutputStream(new FileOutputStream("file.txt"));
        HungerySingleton object = HungerySingleton.getInstance();
        os.writeObject(object);*/
        ObjectInputStream is = new ObjectInputStream(new FileInputStream("file.txt"));
        HungerySingleton test =(HungerySingleton)is.readObject();
        HungerySingleton instance = HungerySingleton.getInstance();
        System.out.println("两者一样否:"+(test==instance));
    }
}
